export default function(Vue){
	Vue.mixin({
		methods:{
			$request(methods,url,data){
				return new Promise((resolve,reject)=>{
					uni.request({
						methods,
						url,
						data,
						success:({
							data
						})=>{
							resolve(data)
						},
						fail(err){
							console.log('接口出错',err)
							reject(err)
						}
					})
				})
			},
			$get(url,data){
				return this.$request('GET',url,data)
			},
			$post(url,data){
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'  
					   }, 
					url, 
					method: 'POST',
					data,
					dataType:'json',
				    success: (res) => {
						console.log(res.data);
					} 
				});
			}
		}
	})
}